/**
*   FuzzyEngine - an Simple flex framework 
*   Copyright (C) 2010 Constantin Aldea
*
*   This program is free software: you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation, either version 3 of the License, or
*   (at your option) any later version.
*   This program is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package main.com.sibilla.gadgets
{

import flash.utils.getDefinitionByName;

import mx.core.Singleton;

/**
 *  This class is used to get a single instance of the  IContext
 *  implementation.
 *  The IContext  support  model standard for Flex applications in lispa.
 *
 *  <p>A single instance of an IContext implementation
 *  manages all localized resources
 *  for a Flex application.</p>
 *  
 *  @see com.fuzzy.flex.interfaces.IContext
 *  @see com.fuzzy.flex.interfaces.AbstractContext
 */
public final class Gadgets 
{
    

    //--------------------------------------------------------------------------
    //
    //  Class variables
    //
    //--------------------------------------------------------------------------



    /**
     *  @private
     *  The sole instance of the IContext.
     */
    private static var instance:GadgetImpl;
    
    //--------------------------------------------------------------------------
    //
    //  Class methods
    //
    //--------------------------------------------------------------------------

    /**
     *  Gets the single instance of the ContextImpl class.
     *  This object manages all ContextImpl resources for a Flex application.
     *  
     *  @return An object implementing IContext.
     */
    public static function getInstance():GadgetImpl
    {
        if (!instance)
        {
            try
			{
				Singleton.registerClass("com.fuzzy.flex.interfaces::IGadget", Class(getDefinitionByName("com.fuzzy.flex.gadgets::GadgetImpl")));
				instance = GadgetImpl(Singleton.getInstance("com.fuzzy.flex.interfaces::IGadget"));
			}catch(e:Error)
			{
				
				instance = new GadgetImpl();
			}
        }
        
        return instance;
    }
    
    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------

    /**
     *  Constructor.
     */
    public function Gadgets()
    {
       
    }
    
}

}